#include "ImageRgb.h"
#include "DiskXFile.h"
#include "xtprobeImageDiskXFile.h"
//#include "tp5Region.h"
//#include "LinkRegion.h"
#include "tp5.h"
#include <CmdLine.h>

using namespace Torch;


int main(int argc, char **argv)
{
	char *image_filename;	
	bool verbose;
 	int threshold1;
	int threshold2;
	bool variance;
	bool mean;
	bool max;
	bool minmax;
	CmdLine cmd;
  	cmd.setBOption("write log", false);
    	
    	cmd.addText("\nArguments:");
    	
	cmd.addSCmdArg("image filename", &image_filename, "image filename");
    	cmd.addText("\nOptions:");
	cmd.addBCmdOption("-verbose", &verbose, false, "verbose");
	cmd.addBCmdOption("-variance",&variance,false,"variance");
	cmd.addBCmdOption("-mean",&mean,false,"mean");
	cmd.addBCmdOption("-max",&max,false,"max");
	cmd.addBCmdOption("-minmax",&minmax,false,"minmax");
    	cmd.addICmdOption("-threshold1", &threshold1, 60, "threshold one");//60 bon pour max-min
	cmd.addICmdOption("-threshold2", &threshold2,40, "threshold two");//40 bon pour max-min		
	cmd.read(argc, argv);
	
	Process *process = new Process(image_filename);
	
	if(variance)		
		process->segmentation(threshold1,threshold2,0);
	if(minmax)
		process->segmentation(threshold1,threshold2,2);
	if(mean)
		process->segmentation(threshold1,threshold2,1);
	if(max)
		process->segmentation(threshold1,threshold2,3);

	ImageRgb *outputImage = new ImageRgb(process->m_iWidth, process->m_iHeight);

	if(variance)
		process->printImage(outputImage,0);
	if(minmax)
		process->printImage(outputImage,2);
	if(mean)
		process->printImage(outputImage,1);
	if(max)
		process->printImage(outputImage,3);
	
	delete outputImage;

	return (0);
}
